View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.toWs;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
21  
22  /***
23   * abstract class writer
24   *
25   * @author Srianth Perera(hemapani@opensource.lk)
26   */
27  public abstract class JavaClassWriter extends AbstractWriter {
28      protected String qulifiedName;
29      protected String classname;
30      protectedong> String packageName;
31      private String pacakgesatement;
32      private String targetDirectory;
33  
34      public JavaClassWriter(J2EEWebServiceContext j2eewscontext, String qulifiedName) throws GenerationFault {
35          super(j2eewscontext, Utils.getFileNamefromClass(j2eewscontext, qulifiedName));
36          this.qulifiedName = qulifiedName;
37          packageName = Utils.getPackageNameFromQuallifiedName(qulifiedName);
38          classname = Utils.getClassNameFromQuallifiedName(qulifiedName);
39      }
40  
41      public void writeCode() throws GenerationFault {
42          if (out == null)
43              return;
44          out.write((packageName != null) ? ("package " + packageName + ";\n") : "");
45          writeImportStatements();
46          writeClassComment();
47          out.write("public class "
48                  + classname
49                  + getExtendsPart()
50                  + getimplementsPart()
51                  + "{\n");
52          writeAttributes();
53          writeConstructors();
54          writeMethods();
55          out.write("}\n");
56      }
57  
58      protected String getExtendsPart() {
59          return " ";
60      }
61  
62      protected String getimplementsPart() {
63          return " ";
64      }
65  
66      protected void writeClassComment() throws GenerationFault {
67      }
68  
69      protected void writeImportStatements() throws GenerationFault {
70      }
71  
72      protected abstract void writeAttributes() throws GenerationFault;
73  
74      protected abstract void writeConstructors() throws GenerationFault;
75  
76      protected abstract void writeMethods() throws GenerationFault;
77  }